home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3171 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: news.lpr.carel.fi!usenet
  2. From: Ari Lukumies <aril@cmt.lpr.mail.carel.fi>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Help!
  5. Date: Fri, 26 Jan 1996 17:38:57 +0200
  6. Organization: Carelcomp Forest
  7. Message-ID: <3108F591.5BC2@cmt.lpr.mail.carel.fi>
  8. References: <4ea5p4$j0s@ratree.psu.ac.th>
  9. NNTP-Posting-Host: renoir.cclahti.carel.fi
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0b6a (WinNT; I)
  14.  
  15. Sanon CHAOCHAIYAPORN wrote:
  16. > Dear all
  17. >         There is a file, hi.bat, in my 'h:\data' directory and I try to
  18. > run it by C program but it fail. Please, advice to me?
  19. > Source:
  20. > #include<stdio.h>
  21. > #include<stdlib.h>
  22. > #include<conio.h>
  23. > #include<dir.h>
  24. > main()
  25. > {
  26. > clrscr();
  27. > chdir("h:\data");
  28. > system("hi.bat");
  29. > getch();
  30. > }
  31.  
  32. You must be kidding? First, rename the file to hi.c, compile it using a C 
  33. compiler, link it using a linker and then run the executable (hi.exe) produced. 
  34. This will of course change the line system to run "hi.exe". Also, you might 
  35. want to declare main as int main(int argc, char **argv)...
  36.  
  37. If you really want to do it as a BAT file, rewrite hi.bat as:
  38.  
  39.     :lbl
  40.     cls
  41.     cd h:\data
  42.     pause
  43.     goto lbl    (or, if you want: hi.bat)
  44.  
  45. and just start it from the command prompt.
  46.  
  47. Later,
  48. AriL
  49. -- 
  50. All my opinions are mine and mine alone.
  51.